<template>
  <div class="z-list">
    <ul>
      <li v-for="(item, index) in array" :key="item.title + index">
        <div class="head">
          <img :src="require('@/assets/imgs/index/111.png')" alt="" />
        </div>
        <div class="bottom">
          <div class="title">
            <div class="text-hidden">{{ item.title }}</div>
            <p class="two-line">{{ item.cont }}</p>
          </div>
          <div class="bot flex-c-b">
            <div class="left">
              <span style="margin-right: 20px; font-size: 12px">{{
                item.flag
              }}</span>
              <span class="list"><i></i> {{ item.link }}</span>
            </div>
            <div class="right" @click="viewDetail">详情</div>
          </div>
          <div class="star" @click="collectFn">
            <i class="el-icon-star-off" v-if="showStar"></i>
            <i v-else class="el-icon-star-on"></i>
          </div>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: "z-list",
  props: {
    list: {
      type: Array,
      default: () => []
    }
  },
  data () {
    return {
      array: [],
      showStar: true
    }
  },

  created () {
    this.array = this.list
  },
  methods: {
    viewDetail () {
      this.$message.info("hello..")
    },
    collectFn () {
      this.showStar = !this.showStar
      this.$message.info(`${this.showStar ? "已取消收藏" : "收藏成功"}`)
    }
  }
}

</script>
<style scoped lang='scss'>
.z-list {
  margin: 20px 0 20px 0;
  ul {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    li {
      margin-top: 20px;
      width: 30%;
      padding-bottom: 12px;
      box-shadow: 0px 2px 5px 0 rgb(196, 191, 191);
      &:hover {
        box-shadow: 0px 2px 12px 0 rgb(133, 131, 131);
      }
      .head {
        height: 260px;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .bottom {
        position: relative;
        padding: 0 10px;
        margin-top: 10px;
        .title {
          & > div {
            font-size: 18px;
            font-weight: 700;
            width: 70%;
          }
          & > p {
            margin-top: 8px;
            font-size: 12px;
            width: 70%;
          }
        }
        .bot {
          font-size: 18px;
          margin-top: 30px;
          .left {
            span {
              display: inline-block;
            }
            .list {
              i {
                display: inline-block;
                width: 25px;
                height: 25px;
                border-radius: 50%;
                background-color: $main_color;
                margin-right: 5px;
              }
            }
          }
          .right {
            cursor: pointer;
            text-decoration: underline;
          }
        }
        .star {
          position: absolute;
          top: 10px;
          right: 10px;
          cursor: pointer;
        }
        .el-icon-star-off,
        .el-icon-star-on {
          font-size: 40px;
        }
      }
    }
  }
}
</style>